//
//  FPViewController.m
//  FPIjkplayerOptimizedFrameWork
//
//  Created by YannChee on 12/02/2021.
//  Copyright (c) 2021 YannChee. All rights reserved.
//

#import "FPViewController.h"
#import <IJKMediaFramework/IJKFFMoviePlayerController.h>

@interface FPViewController ()
@property(nonatomic, strong) IJKFFMoviePlayerController *player;
@property(nonatomic, strong) UIView *playerView;
@end

@implementation FPViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.view.backgroundColor = UIColor.yellowColor;
    
    NSURL *url = [NSURL URLWithString:@"http://vjs.zencdn.net/v/oceans.mp4"];
#ifdef DEBUG
    [IJKFFMoviePlayerController setLogReport:YES];
    [IJKFFMoviePlayerController setLogLevel:k_IJK_LOG_DEBUG];
#else
    [IJKFFMoviePlayerController setLogReport:NO];
    [IJKFFMoviePlayerController setLogLevel:k_IJK_LOG_INFO];
#endif

    [IJKFFMoviePlayerController checkIfFFmpegVersionMatch:YES];
    

    IJKFFOptions *options = [IJKFFOptions optionsByDefault];

    self.player = [[IJKFFMoviePlayerController alloc] initWithContentURL:url withOptions:options];
    self.player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    self.player.view.frame = CGRectMake(50, 50, 300, 300);
    self.player.view.backgroundColor = [UIColor redColor];
    self.player.scalingMode = IJKMPMovieScalingModeAspectFit;
    self.player.shouldAutoplay = YES;

    self.view.autoresizesSubviews = YES;
    [self.view addSubview:self.player.view];

    [self.player prepareToPlay];
}
@end
